<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Flot Examples: Navigation</title>
    <link href="../examples.css" rel="stylesheet" type="text/css">
    <style type="text/css">

    #placeholder .button {
        position: absolute;
        cursor: pointer;
    }

    #placeholder div.button {
        font-size: smaller;
        color: #999;
        background-color: #eee;
        padding: 2px;
    }
    .message {
        padding-left: 50px;
        font-size: smaller;
    }

    </style>
    <script language="javascript" type="text/javascript" src="../../source/jquery.js"></script>
    <script language="javascript" type="text/javascript" src="../../lib/jquery.event.drag.js"></script>
    <script language="javascript" type="text/javascript" src="../../lib/jquery.mousewheel.js"></script>
    <script language="javascript" type="text/javascript" src="../../source/jquery.canvaswrapper.js"></script>
	<script language="javascript" type="text/javascript" src="../../source/jquery.colorhelpers.js"></script>
	<script language="javascript" type="text/javascript" src="../../source/jquery.flot.js"></script>
	<script language="javascript" type="text/javascript" src="../../source/jquery.flot.saturated.js"></script>
	<script language="javascript" type="text/javascript" src="../../source/jquery.flot.browser.js"></script>
	<script language="javascript" type="text/javascript" src="../../source/jquery.flot.drawSeries.js"></script>
	<script language="javascript" type="text/javascript" src="../../source/jquery.flot.uiConstants.js"></script>
	<script language="javascript" type="text/javascript" src="../../source/jquery.flot.touchNavigate.js"></script>
	<script language="javascript" type="text/javascript" src="../../source/jquery.flot.touch.js"></script>
    <script type="text/javascript">

    $(function() {

        function sumf(f, t, m) {
            var res = 0;
            for (var i = 1; i < m; ++i) {
                res += f(i * i * t) / (i * i);
            }
            return res;
        }

        function panMessage(placeholder) {
            placeholder.bind("plotpan", function (event, plot) {
                var axes = plot.getAxes();
                $(".message").html("Panning to x: "  + axes.xaxis.min.toFixed(2)
                + " &ndash; " + axes.xaxis.max.toFixed(2)
                + " and y: " + axes.yaxis.min.toFixed(2)
                + " &ndash; " + axes.yaxis.max.toFixed(2));
            });
        }

        function zoomMessage(placeholder) {
            placeholder.bind("plotzoom", function (event, plot) {
                var axes = plot.getAxes();
                $(".message").html("Zooming to x: "  + axes.xaxis.min.toFixed(2)
                + " &ndash; " + axes.xaxis.max.toFixed(2)
                + " and y: " + axes.yaxis.min.toFixed(2)
                + " &ndash; " + axes.yaxis.max.toFixed(2));
            });
        }

        var d0 = [];
        for (var t = 0; t <= 2 * Math.PI; t += 0.01) {
            d0.push([sumf(Math.cos, t, 10), sumf(Math.sin, t, 10)]);
        }

        var data = [d0],
            placeholder = $("#placeholder"),
             plot = $.plot(placeholder, data, {
                series: {
                    lines: {
                        show: true
                    },
                    shadowSize: 0
                },
                xaxis: {
                    zoomRange: [0.1, 10],
                    panRange: [-10, 10],
                    gridLines: true,
                    autoScale: 'exact'
                },
                yaxis: {
                    zoomRange: [0.1, 10],
                    panRange: [-10, 10],
                    gridLines: true,
                    autoScale: 'exact'
                },
                zoom: {
                    interactive: true,
                    enableTouch: true
                },
                pan: {
                    interactive: true,
                    enableTouch: true
                }
            });

        function piTickGenerator(axis) {
              var res = [],
               i = Math.floor(axis.min / Math.PI);
              do {
                    var v = i * Math.PI;
                    res.push([v, i + "\u03c0"]);
                    ++i;
              } while (v < axis.max);
              return res;
        }

        var d1 = [],
            d2 = [[0.1, 3], [4, 8], [8, 5], [9, 13]],
             d3 = [[0.1, 12], [5, 5], null, [9, 2.5], [12, 5]],
            d4 = [];

        for (var i = 0; i < 14; i += 0.2) {
              d1.push([i, (10 + Math.sin(i))]);
        }

        for (var i = 0; i < 14; i += 0.5) {
              d4.push([i, 1000 + 300 * Math.sin(i)]);
        }

        var placeholder2 = $("#placeholder2"),
            plot2 = $.plot(placeholder2, [ { data: d4, label: "a", xaxis: 1, yaxis: 1 },
                                            { data: d1, label: "b", xaxis: 2, yaxis: 2 } ], {
                series: {
                  lines: {
                    show: true
                  },
                  points: {
                    show: true
                  }
                },
                xaxes: [ {autoScale: 'exact'}, {autoScale: 'exact'} ],
                yaxes: [ { mode: 'log', showTickLabels: 'all', autoScale: 'exact'},
                        { mode: 'log', showTickLabels: 'all', autoScale: 'exact'} ],
                zoom: {
                    interactive: true,
                    enableTouch: true
                },
                pan: {
                    interactive: true,
                    enableTouch: true
                }
        });

        panMessage(placeholder);
        zoomMessage(placeholder);

        panMessage(placeholder2);
        zoomMessage(placeholder2);

        // Add the Flot version string to the footer
        $("#footer").prepend("Flot " + $.plot.version + " &ndash; ");
    });

    </script>
</head>
<body>

    <div id="header">
        <h2>Navigation</h2>
    </div>

    <div id="content">

        <div class="demo-container">
            <div id="placeholder" class="demo-placeholder"></div>
        </div>
    <div class="demo-container">
        <div id="placeholder2" class="demo-placeholder"></div>
    </div>
        <p class="message"></p>

        <p>With the navigateTouch plugin it is easy to add panning and zooming. Drag to pan with one or two fingers, pinch to zoom.</p>

        <p>The plugin fires events (useful for synchronizing several plots) and adds a couple of public methods so you can easily build a little user interface around it, like the little buttons at the top right in the plot.</p>

    </div>

    <div id="footer">
        Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
    </div>

</body>
</html>
